import axios from '@/libs/axios1'
let jsonHeaders = {
	'content-type': 'application/json;charset=UTF-8'
}
let task = '/process/tasks'
//查询任务列表
export const queryTaskList = params => {
	return axios({
		url: `${task}`,
		method: 'GET',
		headers: jsonHeaders,
		params
	})
}

//添加任务
export const addTask = data => {
	return axios({
		url: `${task}`,
		method: 'POST',
		data,
		headers: jsonHeaders
	})
}

//更新任务
export const updateTask = (taskId,data) => {
	return axios({
		url: `${task}/${taskId}`,
		method: 'PUT',
		data,
		headers: jsonHeaders
	})
}

//删除任务
export const delTask = (taskId,data) => {
	return axios({
		url: `${task}/${taskId}`,
		method: 'DELETE',
		headers: jsonHeaders
	})
}

// 操作试验
export const operateTest = (testId,active) => {
	return axios({
		url:`/process/tests/${testId}/execute?operation=${active}`,
		method:'post',
		headers: jsonHeaders
	})
}

//查询试验节点和连线
export const getSceneEditor = (testId) => {
	return axios({
		url:`/process/tests/${testId}/editor`,
		method:'get',
		headers: jsonHeaders
	})
}

//获取试验状态
export const getTestStatus = (testId) => {
	return axios({
		url:`/process/tests/${testId}/status`,
		method:'get',
		headers: jsonHeaders
	})
}

// 查询任务
export const getHistoriesInfo = (taskId) => {
	return axios({
		url: `${task}/${taskId}/histories`,
		method: 'get',
		headers: jsonHeaders
	})
}

// 查询已部署端口信息
export const deployedPortsInfo = (id) => {
	return axios({
		url: `topo-edit/deployed/ports/${id}`,
		method: 'get',
		headers: jsonHeaders
	})
}
// 工程端口列表
export const deployedProjectsList = (projectId,params) => {
	return axios({
		url: `topo-edit/deployed/projects/${projectId}/ports`,
		method: 'get',
		params,
		headers: jsonHeaders
	})
}


// 初始化
export const operateExecute = (testId,active) => {
	return axios({
		url:`${task}/${testId}/execute?operation=${active}`,
		method:'post',
		headers: jsonHeaders
	})
}

// 获取任务详细信息
export const getTaskDetail = (testId,active) => {
	return axios({
		url:`${task}/${testId}`,
		method:'get',
		headers: jsonHeaders
	})
}


